package cn.edu.nwsuaf.teachercenter.aop;

import org.springframework.util.Assert;


/****
 * 切换数据源
 * @author Fantacy
 *
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DataSourceSwitcher {
	
	private static final ThreadLocal contextHolder = new ThreadLocal();

	public static void setMaster() {
		contextHolder.remove();
	}


	public static void setSlave() {
		Assert.notNull("slave", "dataSource cannot be null");
		contextHolder.set("slave");
	}


	public static String getDataSource() {
		Object source = contextHolder.get();
		return (String) source;
	}

}
